import React,{Component} from "react";
import "./index.css";
class dargDiv extends Component{
    state={
        left:0,
        top:0
    }
    render(){
        return <div className="tag" onMouseDown={this.mouseDown.bind(this)} style={{left:this.state.left,top:this.state.top}}></div>
    }
    mouseDown(e){
        let left=e.clientX-e.target.offsetLeft;
        let top=e.clientY-e.target.offsetTop;
        let that=this;
        document.onmousemove=function(e){
            that.setState({left:e.clientX-left,top:e.clientY-top})
        }
        document.onmouseup=function(){
            document.onmousemove=null;
        }
    }
}
export default dargDiv;